<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>

    /**
     * 阿飞摆摊卖小吃了
     */


    /**
     * 牛排
     */

    class Steak{
        constructor(){
            this.price = 30
            this.time = 20
        }
        done(){
            console.log("Steak制作完成，价格：" + this.price + "耗时：" + this.time);
        }
    }

    /**
     * 烧烤
     */

    class Grill{
        constructor(){
            this.price = 20
            this.time = 15
        }
        done(){
            console.log("Grill制作完成，价格：" + this.price + "耗时：" + this.time);
        }
    }

    /**
     * 面条
     */

    class Noodles{
        constructor(){
            this.price = 15
            this.time = 10
        }
        done(){
            console.log("Noodles制作完成，价格：" + this.price + "耗时：" + this.time);
        }
    }

    let a = new Steak()
    a.done()

    let b = new Grill()
    b.done()

    let c = new Noodles()
    c.done()

    /**
     * 开个对外的窗口
     */
    function shop(w){

        /**
         * 牛排
         */

        class Steak{
            constructor(){
                this.price = 30
                this.time = 20
            }
            done(){
                console.log("Steak制作完成，价格：" + this.price + "耗时：" + this.time);
            }
        }

        /**
         * 烧烤
         */

        class Grill{
            constructor(){
                this.price = 20
                this.time = 15
            }
            done(){
                console.log("Grill制作完成，价格：" + this.price + "耗时：" + this.time);
            }
        }

        /**
         * 面条
         */

        class Noodles{
            constructor(){
                this.price = 15
                this.time = 10
            }
            done(){
                console.log("Noodles制作完成，价格：" + this.price + "耗时：" + this.time);
            }
        }

        let o = null
        switch (w) {
            case "Steak":
                o = new Steak()
                break
            case "Grill":
                o = new Grill()
                break
            case "Noodles":
                o = new Noodles()
                break
        }

        return o
    }

    class Shop{
        constructor(w){
            let o = null
            switch (w) {
                case "Steak":
                    o = new Steak()
                    break
                case "Grill":
                    o = new Grill()
                    break
                case "Noodles":
                    o = new Noodles()
                    break
            }

            return o
        }
    }

    let d = new Shop("Steak")
    d.done()
</script>
</body>
</html>